import store from '../store/index.js';
import {
	dateUtils
} from './DateUtil.js';
import router from '../router/router.js'
import routerConfig from '../router/routerConfig.js'
import api from '../api/index.js'


export function hellow() {
	console.log('hellow common');
}
export function userLogin() {

}
export function userInfoRefresh() {
	return new Promise((resolve, reject) => {
		api.get_user_info().then((res) => {
			store.commit('refreshUserInfo', res.data)
			resolve(res.data)
		})
	});
}
export function showSuccessToast({
	title = 'tip'
}) {
	uni.showToast({
		title: title
	});
}
export function showErrorToast({
	title = 'tip'
}) {
	uni.showToast({
		title: title,
		icon: 'none'
	});
}


export function showLoading() {

	uni.showLoading({
		title: '加载中',
		mask: true
	});

}
export function showLoading1({
	hehehe = ''
}) {

	uni.showLoading({
		title: hehehe,
		mask: true
	});

}

export function hideLoading() {
	uni.hideLoading();

}

export function confirm({
	title = '提示',
	content = '这是一个模态弹窗'
}) {

	return new Promise((resolve, reject) => {
		uni.showModal({
			title: title,
			content: content,
			success: function(res) {
				if (res.confirm) {
					resolve(true)
				} else if (res.cancel) {
					resolve(false)
				}
			}
		});
	});
}


export function getVersionCode(){
	return 'aaa';
}

export default {
	hellow,
	userLogin,
	showSuccessToast,
	showErrorToast,
	userInfoRefresh,
	showLoading,
	hideLoading,
	confirm,
	getVersionCode
	
}
